import com.bite.www.TestDomo;

import java.util.Arrays;
import java.util.Date;
//import static java.lang.Math.*;
//import static java.lang.System.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2024-05-19
 * Time: 17:12
 */
class Student {
    private String name;
    private int age;
    private int stuNum;//成员变量 依赖对象
    public static String className;//类变量，不需要实例化，通过类名来访问 存在于方法区

   //快捷键生成访问私有成员变的公共成员方法：alt+insert-->Setter and Getter
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getStuNum() {
        return stuNum;
    }

    public void setStuNum(int stuNum) {
        this.stuNum = stuNum;
    }

    public Student() {
        this("wangwu",18,20240101);
        System.out.println("这是无参的构造方法");
    }
    /*public  Student(String name, int age, int stuNum) {
        this.name = name;
        this.age = age;
        this.stuNum = stuNum;
        System.out.println("这是有3个形参的构造方法");

    }*/

    public Student(String name, int age, int stuNum) {
        this.name = name;
        this.age = age;
        this.stuNum = stuNum;
    }//快捷键生成构造方法：alt+insert->Constructor

    public void show() {
        System.out.println("班级：" + this.name + " 年龄：" + this.age +
        " 学号：" + this.stuNum + " 班级：" + className);
    }

    public void eat() {
        System.out.println(this.name + "吃东西...");
    }
    public void doClass() {
        System.out.println(this.name + "上课...");
    }
}
public class Test {
    public static void main(String[] args) {
        Student.className = "1班";//合法合理
        Student student1 = new Student("zhangsan",19,202022);
        student1.className ="1班";//合法但不合理
        student1.show();
        Student student2 = new Student("wangwu",20,202022);
        student2.show();
        Student student3 = new Student("lisi",19,202024);
        student3.show();
    }
    public static void main5(String[] args) {
        double x = 10;
        double y =20;
        double ret = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
        //使用import static导入包中静态的方法和字段
        //import static java.lang.Math.*;
//        double ret1 = sqrt(pow(x,2)+pow(y,2));//静态导入的方式
        System.out.println(ret);
//        System.out.println(ret1);
        //import static java.lang.System.*;
//        out.println(ret1);//静态导入的方式
    }
    public static void main4(String[] args) {

        //java.util.Date date = new java.util.Date();
        Date date = new Date();
        System.out.println(date.getTime());//个毫秒级别的时间戳

        //当使用不同包中的类但是是相同名字的类时，使用第二个类时需要使用完整的类名
        java.sql.Date date1 = new java.sql.Date(2);
        System.out.println(date1);
    }
    public static void main3(String[] args) {
        TestDomo testDomo = new TestDomo();
//        System.out.println(testDomo.a);//default限制性修饰符不能在不同的包中使用
    }
    public static void main2(String[] args) {
        Student student1 = new Student();

        //通过公共成员方法使用私有成员变量
        student1.setName("zhangsan");
        System.out.println(student1.getName());
        student1.setAge(20);
        System.out.println(student1.getAge());
        student1.setStuNum(2022210);
        System.out.println(student1.getStuNum());
    }

    public static void main1(String[] args) {

        /*Student student1 = new Student("zhangsan",19,20240210);
        student1.name = "zhangsan";
        student1.age = 19;
        student1.stuNum = 20240210;
        System.out.println(student1.name);
        System.out.println(student1.age);
        System.out.println(student1.stuNum);
        student1.eat();
        System.out.println("-----------");
        Student student2 = new Student();
        student2.name = "lisi";
        student2.age = 20;
        student2.stuNum = 20240211;
        System.out.println(student2.name);
        System.out.println(student2.age);
        System.out.println(student2.stuNum);
        student2.doClass();*/
    }
}
